﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace LWP.Chat.Common
{
    public abstract class ViewModelBase : NotifyPropertyChanged
    {
        public void SetProperty<TProperty>(ref TProperty orgin, TProperty newValue, [CallerMemberName]string propName = null)
        {
            if (object.Equals(orgin, newValue))
            {
                // 原始值和新的值一样 没有必要去通知
                return;
            }
            // 不相等
            orgin = newValue;
            if (string.IsNullOrEmpty(propName))
            {
                return;
            }
            OnPropertyChanged(propName);
        }
    }
}
